package com.ruoyi.ax.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ax.domain.AxWithdrawal;
import com.ruoyi.ax.service.IAxWithdrawalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现记录Controller
 * 
 * @author ruoyi
 * @date 2025-05-19
 */
@RestController
@RequestMapping("/ax/AxWithdrawal")
public class AxWithdrawalController extends BaseController
{
    @Autowired
    private IAxWithdrawalService axWithdrawalService;

    /**
     * 查询提现记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AxWithdrawal axWithdrawal)
    {
        startPage();
        List<AxWithdrawal> list = axWithdrawalService.selectAxWithdrawalList(axWithdrawal);
        return getDataTable(list);
    }

   //我的申请记录
    @GetMapping("/mylist")
    public TableDataInfo mylist(AxWithdrawal axWithdrawal)
    {
        startPage();
        axWithdrawal.setApplyer(SecurityUtils.getUserId()+"");
        List<AxWithdrawal> list = axWithdrawalService.selectAxWithdrawalList(axWithdrawal);
        return getDataTable(list);
    }


    /**
     * 导出提现记录列表
     */
    @Log(title = "提现记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AxWithdrawal axWithdrawal)
    {
        List<AxWithdrawal> list = axWithdrawalService.selectAxWithdrawalList(axWithdrawal);
        ExcelUtil<AxWithdrawal> util = new ExcelUtil<AxWithdrawal>(AxWithdrawal.class);
        util.exportExcel(response, list, "提现记录数据");
    }

    /**
     * 获取提现记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(axWithdrawalService.selectAxWithdrawalById(id));
    }

    /**
     * 新增提现记录
     */
    @Log(title = "提现申请", businessType = BusinessType.UPDATE)
    @PostMapping("/appadd")
    public AjaxResult appadd(@RequestBody AxWithdrawal axWithdrawal)
    {
        axWithdrawal.setApplyer(SecurityUtils.getUserId()+"");
        return toAjax(axWithdrawalService.insertAxWithdrawal(axWithdrawal));
    }
    /**
     * 新增提现记录
     */
    @Log(title = "提现申请审核", businessType = BusinessType.UPDATE)
    @PostMapping("/appaddAudit")
    public AjaxResult appaddAudit(@RequestBody AxWithdrawal axWithdrawal)
    {
       // axWithdrawal.setApplyer(SecurityUtils.getUserId()+"");
        return toAjax(axWithdrawalService.auditAxWithdrawal(axWithdrawal));
    }



        /**
         * 新增提现记录
         */
    @Log(title = "提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AxWithdrawal axWithdrawal)
    {
        return toAjax(axWithdrawalService.insertAxWithdrawal(axWithdrawal));
    }

    /**
     * 修改提现记录
     */
    @Log(title = "提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AxWithdrawal axWithdrawal)
    {
        return toAjax(axWithdrawalService.updateAxWithdrawal(axWithdrawal));
    }

    /**
     * 删除提现记录
     */
    @Log(title = "提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(axWithdrawalService.deleteAxWithdrawalByIds(ids));
    }
}
